package
{
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.net.NetStreamAppendBytesAction;
	import flash.utils.ByteArray;
	
	import cc.minos.codec.MP4Convert;
	import cc.minos.codec.flv.FlvCodec;
	import cc.minos.codec.mp4.Mp4Codec;
	
	public class VideoPlayer extends BasePlayer
	{
		private var mConvert:MP4Convert;
		
		public function VideoPlayer()
		{
			super("D:/shi.mp4");
			
			mConvert = new MP4Convert();
			
			mNetStream.play(null);
			mNetStream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
			mNetStream.seek(0);
			mNetStream.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
		}
		
		override protected function onComplete(event:Event):void{
			trace("onComplete");	
			
			return;
			var byte:ByteArray = new ByteArray();
			mURLStream.readBytes(byte);
			byte.position = 0;
			
			var mp4:Mp4Codec = new Mp4Codec();
			mp4.decode(byte);
			
			var data:ByteArray = new FlvCodec().encode(mp4);
			mNetStream.appendBytes(data);
		}
		
		override protected function onProgress(event:ProgressEvent):void{
			
			//return;
			
			var byte:ByteArray = new ByteArray();
			mURLStream.readBytes(byte);
			byte.position = 0;
			
			trace("onProgress:", byte.length);
			
			var arr:Array = mConvert.addBytes(byte);
			
			trace("length:"+arr.length);
			while(arr.length){
				mNetStream.appendBytes(arr.shift());
			}
		}
	}
}